package com.docker.sys.user.insideUserRole;

import com.docker.core.constant.ConfigConstant;
import com.docker.core.constant.MainConstant;
import com.docker.core.mvc.dao.BaseDao;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.Record;

import java.util.List;

/**
 * @Author ldl
 * @Create 2020/09/23 023 10:01
 */
public class InsideUserRoleDao extends BaseDao {

    @Override
    protected String getDbName() {
        return MainConstant.DB_DOCKER;
    }

    @Override
    protected String getSqlTplNameSpace() {
        return "sys.user.inside.role";
    }

    public List<Record> list(String userId) {
        return tplList("list", userId, PropKit.get(ConfigConstant.SUPER_ADMIN_ROLE));
    }

    public List<Record> now(String userId) {
        return tplList("now", userId);
    }

    public boolean deleteAll(String userId) {
        return tplDelete("delete.all", userId) > 0;
    }

    public boolean save(Record userRole) {
        return save("sys_user_inside_role", "ur_id", userRole);
    }

    public boolean exist(String userId) {
        return tplQueryInt("exist", userId) > 0;
    }

}
